package smdc.web.controller.system;

import java.util.List;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import smdc.common.core.controller.BaseController;
import smdc.common.core.domain.entity.SysExcelRead;
import smdc.common.utils.poi.ExcelUtil;

/**
 * JsonController
 *
 * @author ruoyi
 * @date 2023-10-18
 */
@RestController
@RequestMapping("/system/excel")
public class ExcelController extends BaseController {


    /**
     * 通用上传请求（单个）
     */
    @PostMapping("/readExcelFile")
    public void readExcelFile(@RequestParam("excelFile") MultipartFile file) throws Exception
    {
        // 解析Excel
        ExcelUtil<SysExcelRead> util = new ExcelUtil<SysExcelRead>(SysExcelRead.class);
        List<SysExcelRead> list = util.importExcel(file.getInputStream());
        // 数据处理
        list.forEach(item -> System.out.println(item.getTest()));
        System.out.println(list);

    }



}
